package com.springlearn.zhoufei.other.spring.demo5;

/**
 * 设置数据-实体的映射关系
 * @author zhoufei
 * @class: StudentMapper
 * @date 2020/10/3  9:52
 * @Verson 1.0 -2020/10/3  9:52
 * @see
 */

import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

public class StudentMapper implements RowMapper<Student> {
    @Override
    public Student mapRow(ResultSet rs, int rowNum) throws SQLException {
        Student student = new Student();
        student.setId(rs.getInt("id"));
        student.setName(rs.getString("name"));
        student.setAge(rs.getInt("age"));
        return student;
    }
}